home *** CD-ROM | disk | FTP | other *** search
/ PD Collection CD 1 / PD Collection CD 1.iso / programer2 / sdls / DLLLib_h_dll < prev    next >
Encoding:
Text File  |  1995-03-14  |  4.9 KB  |  184 lines

  1. /*
  2.  * dll.h
  3.  *
  4.  * Definitions for DLLLib
  5.  *
  6.  * © 1994 Straylight
  7.  */
  8.  
  9. #ifndef __dll_h
  10. #define __dll_h
  11.  
  12. /*----- External dependencies ---------------------------------------------*/
  13.  
  14. #ifndef __os_h
  15.   #include "os.h"
  16. #endif
  17.  
  18. #ifndef __kernel_h
  19.   #include "kernel.h"
  20. #endif
  21.  
  22. #ifndef __wimp_h
  23.   #include "wimp.h"
  24. #endif
  25.  
  26. /*----- Type definitions for DLLs -----------------------------------------*/
  27.  
  28. typedef void *dll;                      /* What a DLL handle looks like    */
  29.  
  30. typedef struct                          /* An external DLL table           */
  31. {
  32.   char *name;                           /* Name of DLL to load             */
  33.   int version;                          /* Minimum acceptable version      */
  34.   char *entryNames;                     /* Pointer to entry name table     */
  35.   void *branchTable;                    /* Pointer to branch table to fill */
  36. }
  37. dll_table;
  38.  
  39. typedef struct                          /* A DLL information structure     */
  40. {
  41.   dll d;                                /* The handle of the DLL           */
  42.   char *name;                           /* The DLL's textual name          */
  43.   int version;                          /* The DLL's version number        */
  44.   char *author;                         /* The name of the DLL's author    */
  45.   unsigned instSize;                    /* Size of the DLL's instance vars */
  46. }
  47. dll_infostr;
  48.  
  49. /*----- Interface to DLLManager SWIs --------------------------------------*
  50.  *
  51.  * The sharper eyed amongst you may have noticed that DLL_Prologue doesn't
  52.  * have an entry point here.  This is for several reasons:
  53.  *
  54.  * 1. It's not a very safe call to make if you don't know what you're doing.
  55.  *    Then again, nor are any of the others.
  56.  *
  57.  * 2. It's not all that useful unless you're writing in assembler, in which
  58.  *    case you can call the SWI directly.
  59.  *
  60.  * 3. Hopefully, the cdll program can generate all the code you'll ever need
  61.  *    which calls DLL_Prologue, and you'll never need to mess about with it.
  62.  *
  63.  * Several of the calls listed here suffer badly from lack of usefulness.
  64.  * The only ones that you're really likely to want to use are dll_nameApp,
  65.  * dll_info and dll_findEntry.
  66.  */
  67.  
  68. os_error *dll_find(const char *name,int version,dll *d);
  69. os_error *dll_findFromTable(const dll_table *table,int entries);
  70. os_error *dll_load(void *buffer,const char *name);
  71. os_error *dll_lose(dll d);
  72. os_error *dll_appDying(void);
  73. os_error *dll_giveCLibData(void *data);
  74. os_error *dll_findCLibData(void **p);
  75. os_error *dll_instanceVars(void *buffer,int *size,int *magic);
  76. os_error *dll_setInstanceVars(dll d,void *workspace);
  77. os_error *dll_appData(void);
  78. os_error *dll_readStackPtr(int *sp);
  79. os_error *dll_setStackPtr(int sp);
  80. os_error *dll_nameApp(const char *name);
  81. os_error *dll_info(dll d,dll_infostr *i);
  82. os_error *dll_findEntry(dll d,const char *name,void (**entry)());
  83. os_error *dll_saveHandle(int *handle);
  84. os_error *dll_restoreHandle(int *handle);
  85. os_error *dll_findInstanceVars(dll d,void **addr);
  86. os_error *dll_registerAppEntryTable(void (**btable)(),char *names);
  87. os_error *dll_findAppEntry(char *name,void (**func)());
  88. os_error *dll_setExtensionTable(void (**btable)(),char *names);
  89.  
  90. /*----- Doing nothing at all, but without warnings! -----------------------*/
  91.  
  92. #define _dll_nothing ((void)(0))
  93.  
  94. /*----- Registration with DLLManager --------------------------------------*/
  95.  
  96. #ifndef _dll_NODLL
  97.  
  98. void _dll_appspace(void);
  99. void _dll_clibdata(void);
  100. #define _dll_setname(name) (void)dll_nameApp(name)
  101.  
  102. #else
  103.  
  104. #define _dll_appspace(x) _dll_nothing
  105. #define _dll_clibdata(x) _dll_nothing
  106. #define _dll_setname(name) _dll_nothing
  107.  
  108. #endif
  109.  
  110. /*----- Handling *commands ------------------------------------------------*/
  111.  
  112. #ifndef _dll_NODLL
  113.  
  114. int _dll_system(const char *command);
  115. int _dll_ksystem(const char *command,int chain);
  116. os_error *_dll_oscli(const char *command);
  117. os_error *_dll_starttask(const char *command);
  118.  
  119. #else
  120.  
  121. #define _dll_system(x) system(x)
  122. #define _dll_ksystem(x) _kernel_system(x)
  123. #define _dll_oscli(x) os_cli(x)
  124. #define _dll_starttask(x) wimp_starttask(x)
  125.  
  126. #endif
  127.  
  128. /*----- Handling of extension DLLs ----------------------------------------*/
  129.  
  130. dll _dll_loadExtension(const char *name);
  131. void _dll_freeExtension(dll d);
  132.  
  133. /*----- setjmp and longjmp support ----------------------------------------*/
  134.  
  135. #ifndef _dll_NODLL
  136.  
  137. int _dll_setjmp(void);
  138. void _dll_longjmped(int sp);
  139.  
  140. #else
  141.  
  142. #define _dll_setjmp(x) (0)
  143. #define _dll_longjmped(x) ((x)=(x))
  144.  
  145. #endif
  146.  
  147. /*----- Other miscellaneous calls -----------------------------------------*/
  148.  
  149. #ifndef _dll_NODLL
  150.  
  151. void _dll_giveMemory(void);
  152.  
  153. #else
  154.  
  155. #define _dll_giveMemory(x) _dll_nothing
  156.  
  157. #endif
  158.  
  159. /*----- External names for extentry functions -----------------------------*/
  160.  
  161. #ifdef _DLL
  162.  
  163. #define _dllEntry(name) _dllEntry_ ## name
  164.  
  165. #else
  166.  
  167. #define _dllEntry(name) name
  168.  
  169. #endif
  170.  
  171. #ifndef _dll_NODLL
  172.  
  173. #define _extEntry(name) _extEntry_ ## name
  174. #define _dll_static
  175.  
  176. #else
  177.  
  178. #define _extEntry(name) name
  179. #define _dll_static static
  180.  
  181. #endif
  182.  
  183. #endif
  184.